package com.mf.controller;

import com.mf.dto.PositionsDto;
import com.mf.service.IPositionsService;
import com.mf.utils.Result;
import com.mf.vo.positions.PositionsByUserListVo;
import com.mf.vo.positions.PositionsVo;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

/**
 * <p>
 * 持仓表 前端控制器
 * </p>
 *
 * @author mf
 * @since 2024-05-18
 */
@RestController
@RequestMapping("/stock/positions")
@Tag(name = "持仓表")
public class PositionsController {
    @Resource
    private  IPositionsService positionsService;

    @Operation(summary = "根据用户id查询持仓")
    @GetMapping("/findPositionsByUserId")
    public Result<PositionsVo> findPositionsByUserId(@RequestParam("userId") Integer userId) {
        return Result.success(positionsService.findPositionsByUserId(userId));
    }

    @Operation(summary = "根据持仓列表查询持仓每天的明细")
    @PostMapping("/findPositionsByList")
    public Result<List<Map<String, Object>>> findPositionsByList(@RequestBody PositionsDto positionsDto) {
        return Result.success(positionsService.findPositionsByList(positionsDto));
    }
}
